package cn.com.cmbc;


import cn.com.cmbc.service.FileService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * Hello world!
 *
 */
public class App {
    private static final Logger LOG = LoggerFactory.getLogger(App.class);
    private static final String DEFAULT_PATH = "E:\\BaiduNetdiskDownload";


    public static void main( String[] args ) {
        String path;
        if (args.length > 0) {
            path = args[0];
            Path filePath = Paths.get(path);
            if (!Files.exists(filePath) || !Files.isDirectory(filePath)) {
                LOG.error("无效的路径或不是目录: {}", path);
                throw new IllegalArgumentException("无效的路径或不是目录: " + path);
            }
        } else {
            path = DEFAULT_PATH;
            LOG.info("使用默认读取路径");
//            throw new IllegalArgumentException("缺少必要的参数：path");
        }

        LOG.info("路径读取成功：{}", path);

        FileService fileService = new FileService();
        String pathFileJSON = fileService.getPathFileJSON(path);

        LOG.info("获取到的文件列表：{}\n", pathFileJSON);


    }
}
